package com.sl.ssh.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sl.ssh.bean.User;
import com.sl.ssh.service.UserService;

@Controller
public class MainController {

	@Autowired
	private UserService userService;
	
    @RequestMapping(value = "test", method = RequestMethod.GET)
    public String test() {
        //实际返回的是views/test.jsp ,spring-mvc.xml中配置过前后缀
        return "view";
    }
    
    @RequestMapping(value="index", method = RequestMethod.GET)
    @ResponseBody
    public List<User> findAll(){
    	return userService.findAll();
    }
    
    @RequestMapping(value="findByUserName", method = RequestMethod.GET)
    @ResponseBody
    public User findByUserName(String userName){
    	return userService.findByUserName(userName);
    }
}
